﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CrmWorkflowDependencies
{
    public class DependenciesException : Exception
    {
        const string _Msg = "Error when generating dependencies graph: ";
        public DependenciesException(Exception innerException, string msg) : base(string.Concat(_Msg, msg)) { }

        public DependenciesException(string msg) : this(null, msg) { }
        public DependenciesException(string format, params object[] args) : this(null, string.Format(format, args)) { }

        public static void ThrowIf(bool condition, string msg)
        {
            if (condition)
            {
                throw new DependenciesException(msg);
            }
        }

        public static void ThrowIf(bool condition, string format, params object[] args)
        {
            ThrowIf(condition, string.Format(format, args));
        }
    }
}
